<template>
  <div class="mall-product" @click="onClick">
    <div class="img">
      <van-image
        width="100"
        height="100"
        fit="cover"
        :src="product.image"
      />
    </div>
    <div class="info">
      <div class="label">{{ product.name }}</div>
      <div class="desc">{{ product.desc }}</div>
      <div class="price-section">
        <span class="inventory">库存{{ product.inventory }}件</span>
        <span class="price"><small>￥</small>{{ product.price }}</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'ProductCell',
  props: {
    product: {
      type: Object,
      default () {
        return {}
      }
    }
  },
  data () {
    return {}
  },
  methods: {
    onClick () {
      this.$emit('click', this.product)
    }
  }
}
</script>

<style lang="less">
  .mall-product {
    width: 100%;
    height: 100px;
    background: #fff;
    display: flex;

    + .mall-product {
      margin-top: 10px;
    }

    .img {
      height: 100px;
      width: 100px;
    }

    .info {
      padding: 0 10px;
      color: #333;
      width: 100%;
    }

    .label {
      font-weight: bold;
      margin-top: 10px;
    }

    .desc {
      font-size: 12px;
      color: #666;
      margin-top: 10px;
    }

    .price-section {
      margin-top: 20px;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }

    .price {
      color: red;
      font-size: 20px;
    }

    .inventory {
      font-size: 12px;
      color: #666;
    }
  }
</style>
